package com.timing.finder.framework;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author JingGe(* ^ ▽ ^ *)
 * @date 2023-03-19 16:39
 * @email 1158055613@qq.com
 */
public class BloomFilterContainer {
    private final Map<String, StorableBloomFilter> filterMap = new ConcurrentHashMap<>();

    private BloomFilterContainer() {
    }

    public static BloomFilterContainer getInstance() {
        return InstanceHolder.CONTAINER;
    }

    public StorableBloomFilter getBloomFilter(String applicationName) {
        return filterMap.get(applicationName);
    }

    public void putNewBloomFilter(String applicationName, StorableBloomFilter filter) {
        filterMap.put(applicationName, filter);
    }

    static class InstanceHolder {
        private static final BloomFilterContainer CONTAINER = new BloomFilterContainer();
    }
}
